# -*- codeing = utf-8 -*-
# @Time : 2024/3/28 15:27
# @Author : huangjing
# @File : bibao.py
# @Software : PyCharm
import threading,time
def f(fun):
    def bibao(*args,**kwargs):
        print('调用方法前执行')
        fun(*args,**kwargs)
        print('调用方法后执行')
    return bibao
@f
def a(s):
    print('用户{}登录'.format(s))
def kuaisu(l):
    if len(l) <= 1:
        return l
    z = l[len(l)//2]
    a = [x for x in l if x < z]
    m = [x for x in l if x == z]
    b = [x for x in l if x > z]
    return kuaisu(a)+m+kuaisu(b)
def paixu():
    l = [1,23,4,5,6,3,2,9,8,5]
    le = len(l)
    for i in range(0,le-1):
        for j in range(i+1,le):
            if l[i] > l[j]:
                l[i],l[j] = l[j],l[i]
    return l
def maopao():
    l = [1,23,4,5,6,3,2,9,8,5]
    le = len(l)
    for i in range(0,le-1):
        for j in range(0,le-i-1):
            if l[j] > l[j+1]:
                l[j],l[j+1] = l[j+1],l[j]
    return l
def zishu():
    l = []
    for i in range(2,100):
        t = True
        for j in range(2,int(i**0.5)+1):
            if i % j == 0:
                t = False
                break
        if t:
            l.append(i)
    return l


if __name__ == '__main__':
    s1 = time.time()
    th = threading.Thread(target=maopao)
    th.start()
    s2 = time.time()
    s3 = time.time()
    th2 = threading.Thread(target=paixu)
    th2.start()
    s4 = time.time()
    s5 = time.time()
    th3 = threading.Thread(target=kuaisu,args=([1,23,4,5,6,3,2,9,8,5],))
    th3.start()
    s6 = time.time()
    th.join()
    th2.join()
    th3.join()
    print('maopao:'+str(s2-s1))
    print('paixu:'+str(s4-s3))
    print('kuaisu:'+str(s6-s5))
